MCQ Answer

Read the information given below carefully and write a list comprehension such that the output is: [‘e’, ‘o’]

  w="hello"  v=('a', 'e', 'i', 'o', 'u')

Read the information given below carefully and write a list comprehension such that the output is: [‘e’, ‘o’]

  w="hello"  v=('a', 'e', 'i', 'o', 'u')


नीचे दी गई इन्फॉर्मेशन को ध्यान से पढ़ें और एक लिस्ट लिखें जैसे कि आउटपुट है: [given e ',] o']
Topic : Sequence data types in python

A. [x for w in v if x in v]

B. [x for x in w if x in v]

C. [x for x in v if w in v]

D. [x for v in w for x in w]




Correct Answer is :

B. [x for x in w if x in v]



Explanation
The tuple ‘v’ is used to generate a list containing only vowels in the string ‘w’. The result is a list containing only vowels present in the string “hello”. Hence the required list comprehension is: [x for x in w if x in v].
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz